package com.health.central_authentication;

import com.health.result.ResultUtils;
import com.health.result.ResultVo;
import com.health.security.CentralAuthenticationToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zipeng Li
 * 2021/6/16  11:48
 */
@Slf4j
@RestController
@RequestMapping("/api/user")
public class StudentController {

    @GetMapping("student-info")
    public ResultVo studentInfo(){
        CentralAuthenticationToken authentication = (CentralAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
        return ResultUtils.success("获取用户信息成功", authentication.getStudent());
    }
}
